<template>
  <div>
    <el-table
        :data="tableData"
        style="width: 100%">
      <el-table-column
          label="标单id"
          prop="id"
          width="70">
      </el-table-column>

      <el-table-column
          label="投标工厂"
          prop="factoryname"
          width="150">
      </el-table-column>

      <el-table-column
          label="工厂负责人"
          prop="manager"
          width="150">
      </el-table-column>

      <el-table-column
          label="联系方式"
          prop="connection"
          width="150">
      </el-table-column>

      <el-table-column
          label="投标价格"
          prop="quote"
          width="150">
      </el-table-column>

      <el-table-column label="操作" width="150">
        <template slot-scope="scope">
          <el-button
              size="mini"
              @click="handleEdit(scope.$index, scope.row)">选标
          </el-button>
        </template>
      </el-table-column>
    </el-table>

  </div>
</template>

<script>
export default {
  data() {
    return {
      pageSize: 14,
      total: null,
      tableData: null,
      currentPage:1,
      orderid:null,
    }
  },
  created() {
    this.orderid=this.$route.query.orderid;
    this.getTableData();
  }, methods: {
    handleEdit(index, row) {
      axios.get('http://localhost:8081/tender/selecttender/'+this.orderid+'/'+row.id).then(
          (response) => {
            if(response.data == "success"){
              this.$router.push('/dealerorderlist');
              this.success();
            }else{
              this.failed();
            }
          }
      );

    },
    success() {
      this.$message({
        message: '选标成功!',
        type: 'success'
      });
    },
    page(currentPage) {
      this.currentPage=currentPage;
      this.getTableData();
    },
    getTableData(){
        axios.get('http://localhost:8081/tender/findAllByOrderringid/'+this.orderid).then(
            (response) => {
              this.tableData = response.data;
            }
        );
    },

  }
}
</script>